package com.dgiot.myapplication;


import android.content.res.AssetManager;
import android.view.Surface;

public class EGLHelper {
    protected  long nativePtr;

    protected AssetManager manager;
    public EGLHelper(AssetManager assetManager) {
        this.manager = assetManager;
    }

    public  void surfaceCreated(Surface surface) {
        nativePtrInit();
        n_surfaceCreated(nativePtr, surface);
    }

    public void surfaceChange(int width, int height) {
        nativePtrInit();
        n_surfaceChanged(nativePtr, width, height);
    }

    public void surfaceDestroyed() {
        if (nativePtr != 0) {
            n_surfaceDestroyed(nativePtr);
            nativePtr = 0;
        }
    }

    public void nativePtrInit() {
        if (nativePtr == 0) {
            nativePtr = n_nativePtrInit(manager);
        }
    }

    private  native long n_nativePtrInit(AssetManager assetManager);
    private  native void n_surfaceCreated(long nativePtr, Surface surface);
    private  native void n_surfaceChanged(long nativePtr, int width, int height);
    private native  void n_surfaceDestroyed(long nativePtr);
}
